package com.zimin.cloud.user.common.util;

import com.zimin.common.constant.ServletConstant;
import com.zimin.common.exception.GraceException;
import com.zimin.shared.enums.ResponseStatusEnum;

/**
 * @author 恒利
 * @since 2022/6/22 5:11 PM
 */
public class ServletUtil extends com.zimin.common.utils.ServletUtil {

    /**
     * 获取用户ID
     */
    public static String getCurrentUserId() {
        var token = getRequest().getHeader(ServletConstant.TOKEN);
        var userId = TokenUtil.verifyToken(token);
        GraceException.isNull(userId, ResponseStatusEnum.TOKEN_IS_ERROR);
        return userId;
    }
}
